home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / dev / gg / bing-1.1.3.lha / bing-1.1.3 / src / mod_icmp.h < prev   
C/C++ Source or Header  |  1997-06-06  |  2KB  |  92 lines

  1. /*
  2.  * This file provides a system independant interface to send and
  3.  * receive ICMP messages.
  4.  */
  5.  
  6. #ifndef _mod_icmp_h_
  7. #define _mod_icmp_h_
  8.  
  9. #if defined(__STDC__) || defined(__cplusplus)
  10. #define PROTO(a,b) a b
  11. #else
  12. #define PROTO(a,b) a()
  13. #endif
  14. #ifdef __cplusplus
  15. #define API "C"
  16. #else
  17. #define API
  18. #endif
  19.  
  20. typedef void* icmp_handle;
  21.  
  22. /* initialize the ICMP module, return a pointer to it. */
  23. extern icmp_handle PROTO(
  24.    icmp_open,
  25.    (
  26.     void
  27.    ));
  28.  
  29. /* set a socket option. Returns >= 0 if successful, -1 otherwise */
  30. extern int PROTO(
  31.    icmp_set_option,
  32.    (
  33.     icmp_handle handle,    /* module handle */
  34.     int level,
  35.     int optname,        /* option to be set */
  36.     void *optval,        /* option value */
  37.     int optlen        /* length of option value */
  38.    ));
  39.  
  40. /* set the timeout for receives */
  41. extern void PROTO(
  42.    icmp_set_timeout,
  43.    (
  44.     icmp_handle handle,
  45.     unsigned long timeout    /* timeout in microseconds */
  46.    ));
  47.  
  48. /* get the ID used in packets */
  49. extern unsigned short PROTO(
  50.    icmp_get_id,
  51.    (
  52.     icmp_handle handle
  53.    ));
  54.  
  55. /* send an ICMP message. Returns >= 0 if successful, -1 otherwise */
  56. extern int PROTO(
  57.    icmp_send,
  58.    (
  59.     icmp_handle handle,        /* module handle */
  60.     void *msg,            /* ICMP message contents */
  61.     int msg_size,            /* size */
  62.     struct sockaddr *to_addr,    /* who to send to */
  63.     int to_addr_size        /* sockaddr size */
  64.    ));
  65.  
  66. /*
  67.  * Wait for an ICMP message.
  68.  * Returns:
  69.  * >0: successful, return value is the packet size
  70.  * 0:  timeout
  71.  * -1: interrupted, should be called again
  72.  */
  73. extern int PROTO(
  74.    icmp_recv,
  75.    (
  76.     icmp_handle handle,        /* module handle */
  77.     char *buffer,            /* buffer pointer */
  78.     int buffer_size,        /* buffer size */
  79.     struct sockaddr *from_addr,
  80.     int *from_addr_size,
  81.     double *elapsed            /* elapsed microseconds since last icmp_send */
  82.    ));
  83.  
  84. /* close the ICMP module. Returns >= 0 if successful, -1 otherwise */
  85. extern int PROTO(
  86.    icmp_close,
  87.    (
  88.     icmp_handle handle
  89.    ));
  90.  
  91. #endif    /* End of File */
  92.